<template>
  <div class="pui-table">
    <table>
      <thead>
        <tr>
          <th v-for="column in columns" :key="column.field" :style="{ width: column.width }">
            {{ column.label }}
          </th>
        </tr>
      </thead>
      <tbody>
        <tr v-for="(row, index) in data" :key="index" :class="{ 'stripe': stripe && index % 2 === 1 }">
          <td v-for="column in columns" :key="column.field">{{ row[column.field] }}</td>
        </tr>
      </tbody>
    </table>
  </div>
</template>

<script lang="ts">
import { defineComponent } from 'vue';
export default defineComponent({
  name: 'puiTable',
});
</script>

<script setup lang="ts">
import type { Props } from './interface';

withDefaults(defineProps<Props>(), {
  columns: () => {
    return [];
  },
  data: () => {
    return [];
  },
  stripe: true,
  autoWidth: false,
});
</script>
